{% extends "base.html" %}
{% block title %}编辑教师信息{% endblock %}
{% block content %}
    <h3>编辑教师信息</h3>
    <form action="{{ url_for('edit_teacher', id=teacher.id) }}" method="post">

        <div class="form-group">
            <label for="username">姓名:</label>
            <input type="text" class="form-control" id="username" name="username" value="{{ teacher.username }}" required>
        </div>

        <div class="form-group">
            <label for="age">年龄:</label>
            <input type="number" class="form-control" id="age" name="age" value="{{ teacher.age }}" required>
        </div>

        <div class="form-group">
            <label for="gender">性别:</label>
            <select class="form-control" id="gender" name="gender" required>
                <option value="男" {% if teacher.gender == '男' %}selected{% endif %}>男</option>
                <option value="女" {% if teacher.gender == '女' %}selected{% endif %}>女</option>
            </select>
        </div>

        <div class="form-group">
            <label for="title">职称:</label>
            <input type="text" class="form-control" id="title" name="title" value="{{ teacher.title }}" required>
        </div>

        <div class="form-group">
            <label for="major_id">专业:</label>
            <select class="form-control" id="major_id" name="major_id" required>
                <option value="无专业">无专业</option>
                {% for major in majors %}
                <option value="{{ major.id }}" {% if major.id == teacher.major_id %}selected{% endif %}>{{ major.name }}</option>
                {% endfor %}
            </select>
        </div>

        <div class="form-group">
            <label for="password">密码:</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="输入新密码（不修改则留空）">
        </div>

        <br>

        <button type="submit" class="btn btn-primary">保存</button>

    </form>
    <br>
    {% if is_admin %}
    <a href="{{ url_for('delete_teacher', id=teacher.id) }}" class="btn btn-danger">删除</a>
    {% endif %}
    <a href="{{ url_for('list_teachers') }}" class="btn btn-secondary">返回教师列表</a>
{% endblock %}
